import time

class MyTimer:
    startStatus = False
    stopStatus = False
    result = 0

    def start(self):
        if self.startStatus == False:
            self.startTime = time.time()
            self.startStatus = True
            time.sleep(3)
            return"计时开始..."
        else:
            return"提示：请先调用stop()结束计时"
    def stop(self):
        if self.startStatus :
            self.endTime = time.time()
            self.stopStatus = True
            return"计时结束"
        else:
            return"提示：请先调用start()开始计时"
    def cal(self):
        if self.stopStatus and self.startStatus:
            self.startStatus = False
            self.stopStatus = False
            self.result = self.endTime-self.startTime
            return "总共运行了："+str(self.result)+" ms"
        else:
            if self.startStatus == False:
                return "未开始计时"
            if self.stopStatus == False:
                return "提示：请先调用stop()结束计时"

    def __str__(self):
        return self.cal()
    __repr__ = __str__

    def __add__(self, other):
        return int.__add__(int(other.result),int(self.result))


